import { NextResponse } from 'next/server';
import prisma from '@/lib/prisma';
import { addToQueue } from '@/lib/rabbitmq';

export async function POST(request) {
  const formData = await request.formData();
  const file = formData.get('file');

  if (!file) {
    return NextResponse.json({ error: '没有上传文件' }, { status: 400 });
  }

  // 处理文件上传逻辑
  // ...

  // 创建任务
  const task = await prisma.task.create({
    data: {
      userId: 'user_id', // 需要从会话中获取
      workflowName: 'photo_beautification',
      status: 'pending'
    }
  });

  // 将任务添加到队列
  await addToQueue('image_processing', { taskId: task.id, filePath: 'path_to_uploaded_file' });

  return NextResponse.json({ taskId: task.id });
}